<?php
include __DIR__ . "/config/cors.php";
include __DIR__ . "/database.php";

$cookie = @$_COOKIE['role'];
$uid = @$_GET['uid'];

if (!isset($cookie) or $cookie != "admin") {
    echo json_encode([
        "code" => 401,
        "message" => "无权访问！"
    ]);
    exit;
}

$db = new DB();
// 判断用户是否存在
$sql = "select * from user where id = '$uid'";
$data = $db->selectOne($sql);
if (is_array($data) and count($data) > 0) {
    echo json_encode([
        "code" => 200,
        "message" => "查询成功",
        "data" => $data
    ]);
} else {
    echo json_encode([
        "code" => 202,
        "message" => "用户不存在"
    ]);
}